package com.ddc.study.feature.main.tree;

import com.ddc.study.entity.Tree;
import com.ddc.study.net.NetworkUtil;

import java.util.List;

/**
 * Created on 2018/5/22.
 *
 * @author lshun
 * @version 1.0
 */
class TreePresenter extends TreeContract.IPresenter {
    @Override
    void loadTreeData() {
        Runnable runnable = () -> {
            final List<Tree> treeData = NetworkUtil.getTreeData();

            if (!isViewAttached()) return;
            getView().runOnUIThread(() -> {
                if (!isViewAttached()) return;
                getView().showTreeData(treeData);
            });
        };

        mThreadPool.submit(runnable);
    }
}
